﻿using System.Xml.Serialization;

using Common.Base;

using Menu.Components;

namespace Menu.XmlEntities
{
    public class XmlSpriteTexture : XmlTexture
    {
        [XmlAttribute("SpriteCount")]
        public int SpriteCount { get; set; }

        [XmlAttribute("Time")]
        public int Time { get; set; }

        internal override MenuComponentBase GetComponent(MenuComponentBase parent)
        {
            var comp = new SpriteTexture(this.Id, base.GetComponent(parent), this.Texture, this.SpriteCount, this.Texture.Width);
            
            comp.Time = this.Time;
            comp.SourceDimension = new Dimension(0, 0, comp.Dimension.Width / this.SpriteCount, comp.Dimension.Height);
            comp.Dimension.Width = comp.Dimension.Width / this.SpriteCount;
            
            comp.Settle();

            return comp;
        }
    }
}